<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
function successMsg($msg){
    return ['code' => 200,'msg' => $msg];
}
function errorMsg($msg){
    return ['code' => -1,'msg' => $msg];
}

// 应用公共文件
function getMenuByPid($pid)
{
    $data = Db::table("ad_menu")->where("pid", $pid)->select();
    $res  = [];
    //遍历 递归
    foreach ($data as $key => $value) {
        // 代码段：核心点
        $value['menu'] = getMenuByPid($value['id']);
        $res[]         = $value;
    }
    return $res;
}